package com.meet.controller;

import com.meet.bizservice.TagService;
import com.meet.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import java.util.List;

@RestController
@RequestMapping("/tags")
@CrossOrigin
@Validated
public class MeetTagController {

    @Autowired
    private TagService tagService;

    @GetMapping("/user-interests")
    public Result<?> getUserInterestTags() {
        return tagService.getUserInterestTags();
    }

    @PutMapping("/user-interests")
    public Result<?> updateInterestTags(@RequestBody @Validated InterestTagUpdateRequest request) {
        return tagService.updateInterestTags(request.getInterestTags());
    }

    // Request DTO
    public static class InterestTagUpdateRequest {
        @NotBlank(message = "兴趣标签列表不能为空")
        private List<String> interestTags;

        // Getters and Setters
        public List<String> getInterestTags() {
            return interestTags;
        }

        public void setInterestTags(List<String> interestTags) {
            this.interestTags = interestTags;
        }
    }
}
